﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
using System.Text;

namespace ManageBanking.Models
{
    public class RequestAdminModels
    {
        public void AddRequest(int iduser, int idtype)
        {
            OnlineBankingDataContext odbc = new OnlineBankingDataContext();
            RequestAdmin ra = new RequestAdmin();
            ra.IdUsername = iduser;
            ra.IdType = idtype;
            ra.DateCreate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
            ra.Solved = false;
            //ra.DateCreate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
            odbc.RequestAdmins.InsertOnSubmit(ra);
            odbc.SubmitChanges();

        
        }
        public string getMD5(String str)
        {
            MD5CryptoServiceProvider mdcsp = new MD5CryptoServiceProvider();
            byte[] b = System.Text.Encoding.UTF8.GetBytes(str);
            b = mdcsp.ComputeHash(b);
            StringBuilder s = new StringBuilder();
            foreach (byte by in b)
            {
                s.Append(by.ToString("x2").ToLower());
            }
            return s.ToString();
        }
    }
}
